package com.sui.bigdata.flink.sql.side;

import java.sql.*;
import java.util.Random;

import org.junit.Test;


/**
 * @author YongChen
 * @date 2019/10/9 17:21
 * @description
 * @email yong_chen@sui.com
 */
public class chenyong {


    @Test
    public void test1() throws Exception {
        Statement stmt = null;
        ResultSet rset = null;

        Connection con = DriverManager.getConnection("jdbc:phoenix:10.201.7.125,10.201.7.126,10.201.7.127:2181");
        stmt = con.createStatement();
//        stmt.executeUpdate("drop table if EXISTS cy_phoenix_test");
        stmt.executeUpdate("CREATE TABLE  cy_phoenix_test1 (\n" +
                "   ID VARCHAR NOT NULL  PRIMARY KEY,\n" +
                "   info:COL1 VARCHAR,\n" +
                "   COL2 VARCHAR\n" +
                "  ) SALT_BUCKETS = 10 ");
        stmt.executeUpdate("create local index cy_phoenix_test1_COL1 ON cy_phoenix_test1(COL1)");

        stmt.executeUpdate("upsert into cy_phoenix_test1 values('lll', 'Hello','World')");
        stmt.executeUpdate("upsert into cy_phoenix_test1  values ('hhh','thank','you')");
        stmt.executeUpdate("upsert into cy_phoenix_test1  values ('mmm','thank1','you1')");

        con.commit();

        PreparedStatement statement = con.prepareStatement("select * from cy_phoenix_test1");
        rset = statement.executeQuery();
        while (rset.next()) {
            System.out.println(rset.getString("ID") + " " + rset.getString("COL1") + " " + rset.getString("COL2"));
        }
        statement.close();
        con.close();

    }


}

